<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $this->title;?></title>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/css/main.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/jquery.js"></script>
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/load.js"></script>
<!--时间选择器-->
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/date/calendar.js"></script>
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/date/lang/cn_utf8.js"></script>
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/date/calendar-setup.js"></script>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/js/date/calendar-blue.css" />
<!--colorbox-->
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/colorbox.jquery/jquery.colorbox.js"></script>
<link href="<?php echo $this->baseUrl;?>/files/admin/js/colorbox.jquery/colorbox2.css" rel="stylesheet" type="text/css"/>


<!--bi-->
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/css/bi.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/bi.js"></script>

</head>
<body style="overflow:auto;">
<div id="main" style="clear:both;">
		<div class="bi-body">
			<form id="searchForm" name="searchForm" method="post" action="<?php echo $this->projectUrl(array('action'=>'index'));?>" >
			<div class="bi-search  bi-search-2">
				<div class="bi-s-top"></div>
				<div class="bi-s-center">
					<div class="bi-s-c-con">
						<div class="bi-s-c-sel">
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
							  <tr>
							  	<td colspan="5">
									<!-- 时间选择条 -->
									<div id="timeRange">
										<a onclick="selData('<?php echo $this->projectUrl(array('action'=>'index')) ;?>',1,<?php echo $this->vars['doType'];?>);" class="<?php echo $this->vars['dateType']==1 ? 'currentTimeRange' : ''?>">昨天</a> <a onclick="selData('<?php echo $this->projectUrl(array('action'=>'index')) ;?>',2,<?php echo $this->vars['doType'];?>);" class="<?php echo $this->vars['dateType']==2 ? 'currentTimeRange' : ''?>">最近7天</a> <a onclick="selData('<?php echo $this->projectUrl(array('action'=>'index')) ;?>',3,<?php echo $this->vars['doType'];?>);" class="<?php echo $this->vars['dateType']==3 ? 'currentTimeRange' : ''?>">最近30天</a> <a onclick="selData('<?php echo $this->projectUrl(array('action'=>'index')) ;?>',4,<?php echo $this->vars['doType'];?>);" class="<?php echo $this->vars['dateType']==4 ? 'currentTimeRange' : ''?>">最近三个月</a> <a onclick="selData('<?php echo $this->projectUrl(array('action'=>'index')) ;?>',5,<?php echo $this->vars['doType'];?>);" class="<?php echo $this->vars['dateType']==5 ? 'currentTimeRange' : ''?>">全部</a>&nbsp;&nbsp;&nbsp;&nbsp;
										<span>日期选择</span>：<input name="startTime" type="text" class="input" id="startTime" size="18" value="<?php echo $this->vars['startTime'];?>" /><script type="text/javascript">Calendar.setup({"ifFormat":"%Y-%m-%d","firstDay":0,"showsTime":true,"showOthers":false,"timeFormat":24,"inputField":"startTime","button":"startTime"});</script>
						-
						<input name="endTime" type="text" class="input" id="endTime" size="18" value="<?php echo $this->vars['endTime'];?>" />
						<script type="text/javascript">Calendar.setup({"ifFormat":"%Y-%m-%d","firstDay":0,"showsTime":true,"showOthers":false,"timeFormat":24,"inputField":"endTime","button":"endTime"});</script>
									</div>
									<!-- 时间选择条 -->	
								</td>
								<td rowspan="3">
									<input type="hidden" name="dateType" id="dateType" value="<?php echo $this->vars['dateType'];?>" />
									<input type="hidden" name="doType" id="doType" value="<?php echo $this->vars['doType'];?>" />	
									<input name="search" type="button" id="search" value="" class="s-button" onclick="selData('<?php echo $this->projectUrl(array('action'=>'index')) ;?>',6,<?php echo $this->vars['doType'];?>);"/>								
								</td>
							  </tr>
							  <tr>
								<td colspan="5">地区选择：
									<select name="areas" id="areas" >
									  <option value="">全国</option>
									</select></td>
								</tr>
							  <tr>
								  <td>操作系统：
										<select name="osName" id="osName" size="1">
											<option value="">全部</option>
											<?php foreach($this->osNameRows as $key=>$row) {?>
											<option value="<?php echo $row[0];?>" <?php if($this->vars['osName']==$row[0]){?>selected="selected"<?php }?>><?php echo $row[1];?></option>
											<?php }?>
										</select></td>		
									<td >渠道：</td>
									<td ><div style="position: relative; width:130px;">
										<select  name="select" id="select" class="select-write" onchange="source.value=select.value;source.select()">
											<option value="">==选择==</option>   
											<?php foreach($this->memberRows as $key=>$row) {
												if (trim($row['name'])!=''){
											?>
											  <option value="<?php echo $row['name'];?>" <?php if($this->vars['source']==$row['name']){?>selected="selected"<?php }?>><?php echo $row['name'];?></option>   
											<?php }
												}
											?>
										  </select>   
  							 			 <input type="text" class="text-write" name="source" id="source" value="<?php echo $this->vars['source'];?>"/>
										</div>
									</td>
									<td >SourceId ：</td>
									<td><div style="position: relative; width:130px;" class="sourceId-con">
										<select name="select_sourceId" id="select_sourceId" class="select-write" onchange="sourceId.value=select_sourceId.value;sourceId.select()">
											<option value="">==选择==</option> 
										</select>
										<input type="text" class="text-write" name="sourceId" id="sourceId" value="<?php echo $this->vars['sourceId'];?>"/>
										<input type="hidden" name="default_sourceId" id="default_sourceId" value="<?php echo $this->vars['sourceId'];?>" />
										</div>
										<div class="sourceId-con-loading" style="width:130px;display:none;">加载中...</div>
									</td>
								  </tr>
								</table>
						</div>
									
						
						
					</div>	
				</div>
				<div class="bi-s-bottom"></div>			
			</div>
			</form>
			<div class="clear" style="height:20px;"></div>
			
			<div class="bi-data">
				<div class="bi-d-top">
					<div class="d-t-left">页面分析</div>
					<div class="d-t-right"><span <?php if(count($this->rows)>0){?>class="show"<?php } else {?>class="hide"<?php }?> id="data_02" onclick="showData('02')" style="cursor:pointer;"></span></div>
				</div>
				<div class="bi-d-center clear" id="data02">
					<div class="bi-d-center-bg">
					<!--content start-->
					<?php if(count($this->rows)>0){?>
					<span class="d-line"></span>
					<table class="table">
						<tr class="subject">
							<td>页面</td>
							<td colspan="2">页面浏览</td>
							<td colspan="2">页面点击</td>
						</tr>
						<tr class="subject">
							<td>名称</td>
							<td>次数</td>
							<td>占比(%)</td>
							<td>人数</td>
							<td>占比(%)</td>
						</tr>
						<?php 
						$count = array();
						$count['pv'] = 0;
						$count['uv'] = 0;
						foreach($this->rows as $key=>$row) {
							if( $row['pageId']!='1010' ){									
								$count['pv'] = $count['pv'] + $row['pv'];
								$count['uv'] = $count['uv'] + $row['uv'];
							}
						}
						foreach($this->pageRows as $var=>$element) {
							foreach($this->rows as $key=>$row) {
								if($element['pageId']==$row['pageId'] && $row['pageId']!='1010' ){
									$pvPercent = $count['pv']>0 ? number_format($row['pv']/$count['pv'],4)*100 : 0 ;
									$pvPercent = $pvPercent>100 ? 100 : $pvPercent ;
									$pvPercentInfo =  $pvPercent."%";
									
									$uvPercent = $count['uv']>0 ? number_format($row['uv']/$count['uv'],4)*100 : 0 ;
									$uvPercent = $uvPercent>100 ? 100 : $uvPercent ;
									$uvPercentInfo =  $uvPercent."%";
						?>
							<tr class="dataLine">
								<td><?php echo $row['pageName'];?></td>
								<td><?php echo $row['pv'];?></td>
								<td><?php echo $pvPercentInfo;?></td>
								<td><?php echo $row['uv'];?></td>
								<td><?php echo $uvPercentInfo;?></td>
							</tr>
						<?php
								}
							}
						}
						?>
						<tr class="subject">
							<td>总计</td>
							<td><?php echo $count['pv'];?></td>
							<td><?php echo $count['pv']>0 ? '100%' : '0%'?></td>
							<td><?php echo $count['uv'];?></td>
							<td><?php echo $count['uv']>0 ? '100%' : '0%'?></td>
						</tr>
				  	</table>
					<?php }?>
					<!--content end-->
					</div>
				</div>
				<div class="bi-d-bottom"></div>
			</div>
						
			
			
		</div>
	
</div>
<script language="javascript">
function selData(action,dateType,doType){
    $('#searchForm').attr('action', action);
	$('#dateType').attr('value', dateType);
	$('#doType').attr('value', doType);
    $('#searchForm').submit();
}


<!-- 更新渠道时，更新sourceId start-->
$(function(){
	$("#select").change(function(){
	if($.trim($("#source").val())!=''){
		$(".sourceId-con").hide();
		$(".sourceId-con-loading").show();
		//$("#sourceId").attr('value','');
		var self=$("#select_sourceId")[0];
			 $.ajax({ url: "<?php echo $this->projectUrl(array('controller'=>'act-day-data-pagevisit','action'=>'sourceids'));?>",
				 type:"post",           
				 dataType:"json",
				 data: "source="+$("#source").val(),
				 success:function(data){ 
						self.options.length=0;
						self.options[0] = new Option('==选择==', '');
						var default_val=$("#default_sourceId").val();
						$.each(data,function(i){
							self.options[i+1] = new Option(data[i], data[i]);
							if(default_val==data[i]) {										 
								self.options[i+1].selected=true;																					
							} 
						}); 
						if(data!=''){
							$(".sourceId-con").show();
							$(".sourceId-con-loading").hide();					
						}
				 } 
			 });
		}	
	})
	if($.trim($("#source").val())!=''){
		$("#select").change();
	}
})
<!-- 更新渠道时，更新sourceId  end-->

</script>
</body>
</html>